package com.yhp.dao.impl;

import com.yhp.bean.Grade;
import com.yhp.dao.DBUtils;
import com.yhp.dao.GradeDao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class GradeDaoImple extends DBUtils implements GradeDao {
    @Override
    public List<Grade> getList() {
        ArrayList gs = new ArrayList();
        try {
            String sql ="select * from grade";
            ResultSet resultSet = query(sql,null);
            while (resultSet.next()){
               Grade grade = new Grade();
                grade.setGradeid(resultSet.getInt("gradeid"));
                grade.setGradename(resultSet.getString("gradename"));
                gs.add(grade);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            closeAll();
        }
        return gs;
    }
}
